Skip to content

refactor(graphql): migrate internal marker decorators to auto decorators - #105

Merged
FionaBronwen merged 5 commits into
pinterest:feature/graphqlfrom
timotheeguerin:graphql-internal-auto-decorators
Jul 15, 2026
Merged

refactor(graphql): migrate internal marker decorators to auto decorators#105
FionaBronwen merged 5 commits into
pinterest:feature/graphqlfrom
timotheeguerin:graphql-internal-auto-decorators

Conversation

@timotheeguerin

Copy link
Copy Markdown

What

Migrates the GraphQL library's internal marker decorators from hand-written implementations to compiler internal auto dec declarations, and adopts the tspd gen-extern-signature generated accessors + decorator signature types.

Decorators converted to internal auto dec:

  • @nullable
  • @nullableElements
  • @oneOf — was still using the .decorators-push hack (model.decorators.push(...) / .some(...))
  • @inputType — was an internal-only useStateSet marker whose $inputType decorator fn was dead (never registered)

Why

These decorators just mark a type; they store no meaningful data and had no validation/transform logic. Previously the emitter located them via .decorators scanning or bespoke state helpers. auto dec lets the compiler synthesize the implementation and lets tspd generate strongly-typed is*/set* accessors, removing hand-written state plumbing.

Changes

  • lib/{nullable,one-of,input-type}.tsp: internal auto dec declarations (added input-type.tsp, wired into main.tsp).
  • Deleted src/lib/{nullable,one-of,input-type}.ts — replaced by generated generated-defs/TypeSpec.GraphQL.ts accessors (isNullable/setNullable, isOneOf/setOneOf, isInputType/setInputType, ...).
  • All decorator impls typed with generated *Decorator signatures; $decorators uses satisfies TypeSpecGraphQLDecorators.
  • Build wires up gen-extern-signature; added tspconfig.yaml opting into the auto-decorators experimental feature.
  • Removed now-unused GraphQLKeys state entries.

Decorators intentionally left as-is

@compose, @operationFields, @schema, @graphqlInterface, @mutation/@query/@subscription, @specifiedBy — these carry validation / accumulation / transform logic that auto decorators can't express.

Note

This branch includes the merge of microsoft/main which brings the setAutoDecorator compiler API + tspd setter generation (microsoft#11247) that this refactor depends on. pinterest/feature/graphql was exactly 1 commit behind main (that PR), so the diff surfaces those changes too.

All 368 @typespec/graphql tests pass; lint + prettier clean.

timotheeguerin and others added 5 commits July 14, 2026 07:52
Convert the internal `@nullable`, `@nullableElements`, `@oneOf`, and
`@inputType` marker decorators from hand-written implementations (and the
`.decorators`-push hack) to compiler `internal auto dec` declarations.

- Adopt tspd `gen-extern-signature` generated readers/setters (isNullable,
  setNullable, isOneOf, setOneOf, isInputType, setInputType, ...) instead of
  hand-written state accessors; delete src/lib/{nullable,one-of,input-type}.ts.
- Type all decorator implementations with the generated `*Decorator`
  signatures; `$decorators` uses `satisfies TypeSpecGraphQLDecorators`.
- Wire up gen-extern-signature into the build; add generated-defs/ and
  tspconfig.yaml (auto-decorators experimental feature opt-in).
- Remove now-unused GraphQLKeys state entries for the migrated decorators.
@FionaBronwen
FionaBronwen marked this pull request as ready for review July 15, 2026 18:31
@FionaBronwen
FionaBronwen merged commit a6f9d12 into pinterest:feature/graphql Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants